import { BaseEntity } from 'src/baseEntity';
import { Dept } from 'src/dept/dept.entity';
import { Project } from 'src/project/project.entity';
import { System } from 'src/system/system.entity';
import { UserSys } from 'src/user/userSys.entity';
import { Column, Entity, ManyToOne } from 'typeorm';

export enum WorkStatus {
  applying = 'applying',
  approved = 'approved',
  reject = 'reject',
  done = 'done',
}

@Entity('work')
export class Work extends BaseEntity {
  @ManyToOne(() => Project, (type) => type.works)
  project: Project;

  @ManyToOne(() => System)
  system: System;

  @ManyToOne(() => UserSys)
  user: UserSys;

  @ManyToOne(() => Dept)
  dept: Dept;

  @ManyToOne(() => UserSys)
  approved: UserSys;

  @Column({
    type: 'enum',
    enum: WorkStatus,
    default: WorkStatus.applying,
  })
  status: WorkStatus;

  @Column({
    type: 'double',
  })
  count: number;

  @Column({ nullable: true })
  comment: string;
}
